home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Prograph Classic 2.6.1 / Examples / Utilities / File I⁄O ƒ / File I⁄O.ReadMe < prev   
Encoding:
Text File  |  1994-10-21  |  3.3 KB  |  71 lines  |  [TEXT/ttxt]

  1. Example:      File I/O
  2. Written by:  Prograph International (Lynn McKaig)
  3. Contents:     File I/O.pgs
  4.                    File I/O.ReadMe
  5.  
  6. Needs Prograph Extensions:
  7.                     Math Primitives
  8.                     More Primitives
  9.                     Primitives
  10.  
  11. Needs Libraries to Compile:
  12.                     SCLibrary 2.6
  13.                     Library 2.6
  14.  
  15. Standard Methods That Were Modified:
  16.                    Universal Initial
  17.                    Menu/Quit
  18.                    Application/About
  19.  
  20. Description
  21. -----------
  22. The File IO class contains a set of useful methods for opening, reading, writing and closing files with complete error checking.  The Progress Bar class is a window item that you can update to reflect the progress of reading, writing or any type of processing.
  23.  
  24. How to Use in Your Program
  25. -------------------------
  26. The File IO class can be selectively loaded into your file; the Read File and Write File methods in the Menu class are simply examples of how you might use the methods from that class.  
  27.  
  28. The Progress Bar class is a subclass of Canvas which can be selectively loaded into your file; then when you are creating your own Progress window in the window editor, you can create an item of type Progress Bar.  The Read File and Write File methods in class Menu contain examples of how you initalise and update the progress bar while doing any sort of processing.  The main decision you have to make for your particular situation is what unit you will use to measure the progress of your task - e.g., number of bytes transferred, number of transactions processed.
  29.  
  30.  
  31. CLASS: FileIO
  32.  
  33. • Open Read File
  34. Uses the get-file and open primitives to display a dialog and open an existing file for reading.  Checks return from open primitive for errors.
  35.  
  36. • Read Line
  37. Uses the read-line primitive to read a line from a text file.  Checks result for errors.
  38.  
  39. • Read Block
  40. Uses the read primitive to read a block of the given size from the given file, then checks result for errors.
  41.  
  42. • Check Read Error
  43. When reading files, results of noErr and eofErr are OK, but all others are displayed by calling the "get error message" method.
  44.  
  45. • Close File
  46. Calls the close primitive and checks the result for errors.
  47.  
  48. • Open Write File
  49. Calls the put-file, delete, create and open primitives to open a file for writing.  Checks results of each call for errors.
  50.  
  51. • Write Line
  52. Uses the write-line primitive to write a line to a text file.  Checks result for errors.
  53.  
  54. • Write Block
  55. Uses the write primitive to write a block of the given size to the given file, then checks result for errors.
  56.  
  57. • Check Write Error
  58. When writing a file, any error except noErr gets displayed.
  59.  
  60.  
  61.  
  62. CLASS: Menu
  63.  
  64. • Enable Menu Item
  65. Useful method that enables or disables a menu item of the given name in a menu of the given name.
  66.  
  67. • Read File
  68. Executed when you select "Read File..." from the File menu.   Opens and initialises the window with a Progress Bar, uses methods from the File IO class to read in a text file while updating the progress bar, then closes the file and removes the Progress Window.
  69.  
  70. • Write File
  71. Executed when you select "Write File..." from the File menu.  Opens and initalises the Progress Window, uses methods from the File IO class to write out a text file while updating the progress bar, then closes the file and removes the Progress Window.